﻿using System.Windows;
using System.Windows.Controls;
using System.Collections.Specialized;
using System.Configuration;
using HRMSystem.Util;
using System.Net;
using HRMSystem.Wpf.WpfWindow;
using System.Windows.Input;
using System;
using System.Collections.Generic;
using System.Data;
using HRMSystem.DBServices;


namespace HRMSystem.Wpf.EmployeePages
{
    /// <summary>
    /// Interaction logic for EmployeePage.xaml
    /// </summary>
    public partial class EmployeePage : Page
    {
        private static EmployeePage instance;
        public IList<string> ErrorList { get; set; }

        public EmployeePage()
        {
            InitializeComponent();

            ContentFrame.Content = QuickSearchPage.Instance;

            //var test = ManagerService.GetManagerListByUserNamePassword("Test", "Test");

            //string str = test.ToString();
        }

        public static EmployeePage Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new EmployeePage();
                }

                return instance;
            }
        }

        private void AddEmployeeButton_Click(object sender, RoutedEventArgs e)
        {
            ContentFrame.Content = DetailsPage.Instance;

            MenuDefaultEmployeeDetails.Height = 0;
            MenuAddEmployeeDetails.Height = Double.NaN;
        }

        private void BackButton_Click(object sender, RoutedEventArgs e)
        {
            ContentFrame.Content = QuickSearchPage.Instance;

            MenuAddEmployeeDetails.Height = 0;
            MenuDefaultEmployeeDetails.Height = Double.NaN;
        }

        private void SearchEmployeeButton_Click(object sender, RoutedEventArgs e)
        {
            ContentFrame.Content = SearchPage.Instance;
        }

        private void ChangeTitleButton_Click(object sender, RoutedEventArgs e)
        {
            if (Session.SelectedEmployee == null)
            {
                MessageWindow msg = new MessageWindow(Messages.TTL_MSG, Messages.MSG_SELECT_EMPLOYEE);
                msg.ShowDialog();
                ContentFrame.Content = QuickSearchPage.Instance;

                Session.Navigation = TitleChangePage.Instance;
            }
            else
            {
                ContentFrame.Content = TitleChangePage.Instance;
            }
        }

        private void EditProfileButton_Click(object sender, RoutedEventArgs e)
        {
            if (Session.SelectedEmployee == null)
            {
                MessageWindow msg = new MessageWindow(Messages.TTL_MSG, Messages.MSG_SELECT_EMPLOYEE);
                msg.ShowDialog();
                ContentFrame.Content = QuickSearchPage.Instance;

                Session.Navigation = EditProfilePage.Instance;
            }
            else
            {
                ContentFrame.Content = EditProfilePage.Instance;
            }
        }

        private void LeaveRequestButton_Click(object sender, RoutedEventArgs e)
        {
            if (Session.SelectedEmployee == null)
            {
                MessageWindow msg = new MessageWindow(Messages.TTL_MSG, Messages.MSG_SELECT_EMPLOYEE);
                msg.ShowDialog();
                ContentFrame.Content = QuickSearchPage.Instance;

                Session.Navigation = LeaveRequestPage.Instance;
            }
            else
            {
                ContentFrame.Content = LeaveRequestPage.Instance;
            }
        }

        private void EmployeeDetailsSaveButton_Click(object sender, RoutedEventArgs e)
        {
            DetailsPage.Instance.SaveNewEmployeeDetails();
        }

        private void SelectedEmpLogOutButton_Click(object sender, RoutedEventArgs e)
        {
            Session.LogOutSelectedEmployee();
        }
    }
}
